import { UI_Listen } from '../../config/ui_def'
cc.Class({
    extends: cc.Component,

    properties: {
        head_sp: cc.Sprite,
        highLight: cc.Node,
    },

    init(info, index) {
        this.highLight.active = false
        if (index >= 0) this.index = index
        if (info) {
            this.roleInfo = info
            let name = `head_select_${info.id - 1000}`
            this.head_sp.spriteFrame = he.load.get('rolePage', cc.SpriteAtlas, 'plist').getSpriteFrame(name)
            //改成不让点击了
            this.canClick = true
        }
        else {
            // this.canClick =false
            this.canClick = true
            this.roleInfo = null
            this.head_sp.spriteFrame = null
        }
    },
    showLight() {
        this.highLight.active = true
    },

    hideLight() {
        this.highLight.active = false
    },

    clickServer() {
        if (this.canClick) {
            gg.eventManager.emit('equip', { type: UI_Listen.EQUIP_INDEX, index: this.index, info: this.roleInfo })
        }
    }
});
